<div class="bind-form">
  <form>
    <div class="form-group">
      <label>
        <h3>Create a binding for <strong>{{ctrl.serviceClass.spec.externalMetadata.displayName || ctrl.serviceClass.spec.externalName}}</strong></h3>
      </label>
      <span class="help-block">Bindings create a secret containing the necessary information for an application to use this service.</span>
    </div>
  </form>

  <form ng-if="ctrl.allowNoBinding || ctrl.showPodPresets" name="ctrl.formName" class="mar-bottom-lg">
    <fieldset>
      <div class="radio">
        <label ng-if="ctrl.showPodPresets" class="bind-choice" ng-disabled="!ctrl.applications.length">
          <input type="radio" ng-model="ctrl.bindType" value="application" ng-disabled="!ctrl.applications.length">
          Create a secret and inject it into an application
        </label>
        <div ng-if="ctrl.showPodPresets" class="application-select">
          <ui-select ng-model="ctrl.appToBind"
                     ng-disabled="ctrl.bindType !== 'application'"
                     ng-required="ctrl.bindType === 'application'">
            <ui-select-match placeholder="{{ctrl.applications.length ? 'Select an application' : 'There are no applications in this project'}}">
              <span>
                {{$select.selected.metadata.name}}
                <small class="text-muted">&ndash; {{$select.selected.kind | humanizeKind : true}}</small>
              </span>
            </ui-select-match>
            <ui-select-choices
              repeat="application in (ctrl.applications) | filter : { metadata: { name: $select.search } } track by (application | uid)"
              group-by="ctrl.groupByKind">
              <span ng-bind-html="application.metadata.name | highlight : $select.search"></span>
            </ui-select-choices>
          </ui-select>
        </div>
        <label class="bind-choice">
          <input type="radio" ng-model="ctrl.bindType" value="secret-only">
          Create a secret in <strong>{{ctrl.projectName}}</strong> to be used later
        </label>
        <div class="help-block bind-description">
          Secrets can be referenced later from an application.
        </div>
        <label ng-if="ctrl.allowNoBinding" class="bind-choice">
          <input type="radio" ng-model="ctrl.bindType" value="none">
          Do not bind at this time
        </label>
        <div ng-if="ctrl.allowNoBinding" class="help-block bind-description">
          Bindings can be created later from within a project.
        </div>
      </div>
    </fieldset>
  </form>
</div>
